package com.boot.learning.ctrl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.boot.learning.domain.SimpleUserMysql;
import com.boot.learning.service.SimpleUserMysqlService;

import io.swagger.annotations.ApiOperation;

/**
 * 用户操作ctrl(Mysql)
 *  
 * @since JDK1.8
 * @author vencano
 * @date 2017年1月18日 下午8:05:46
 */
@RestController
@RequestMapping("/users")
public class SimpleUserMysqlCtrl {

	@Autowired
	private SimpleUserMysqlService userService;
	
	@GetMapping
	@ApiOperation(value="查询所有用户")
	public List<SimpleUserMysql> findAll() {
		return userService.findAll();
	}
	
	@PostMapping
	@ApiOperation(value="新增一个用户")
	public SimpleUserMysql registerOne(@RequestBody SimpleUserMysql simpleUser){
		return userService.registerOne(simpleUser);
	}
	
	@PostMapping("/batch")
	@ApiOperation(value="新增一个用户")
	public List<SimpleUserMysql> registerBatch(@RequestBody List<SimpleUserMysql> simpleUsers){
		return userService.registerBatch(simpleUsers);
	}
}
